home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectShow / DMO / DMOSample / Sample.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-08  |  3.6 KB  |  105 lines

  1. //------------------------------------------------------------------------------
  2. // File: Sample.h
  3. //
  4. // Desc: DirectShow sample code - definition of CSample class.
  5. //
  6. // Copyright (c) 2000-2001 Microsoft Corporation.  All rights reserved.
  7. //------------------------------------------------------------------------------
  8.  
  9.  
  10. #ifndef __SAMPLE_H_
  11. #define __SAMPLE_H_
  12.  
  13.  
  14. // df20ddfa-0d19-463a-ab46-e5d8ef6efd69
  15. DEFINE_GUID(CLSID_Sample,
  16.             0xdf20ddfa, 0x0d19, 0x463a, 0xab, 0x46, 0xe5, 0xd8, 0xef, 0x6e, 0xfd, 0x69);
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CSample
  20. class ATL_NO_VTABLE CSample :
  21.     public IMediaObjectImpl<CSample, 1, 2>,        // 1 input, 2 outputs
  22.     public CComObjectRootEx<CComMultiThreadModel>,
  23.     public CComCoClass<CSample, &CLSID_Sample>
  24.     
  25. {
  26. public:
  27.     CSample()
  28.     {
  29.         m_pUnkMarshaler = NULL;
  30.     }
  31.  
  32.  
  33. DECLARE_REGISTRY_RESOURCEID(IDR_SAMPLE)
  34. DECLARE_GET_CONTROLLING_UNKNOWN()
  35.  
  36. DECLARE_PROTECT_FINAL_CONSTRUCT()
  37.  
  38. BEGIN_COM_MAP(CSample)
  39.     COM_INTERFACE_ENTRY(IMediaObject)
  40.     COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  41. END_COM_MAP()
  42.  
  43.     HRESULT FinalConstruct()
  44.     {
  45.         return CoCreateFreeThreadedMarshaler(
  46.             GetControllingUnknown(), &m_pUnkMarshaler.p);
  47.     }
  48.  
  49.     void FinalRelease()
  50.     {
  51.         //  Make sure we clean up
  52.         FreeStreamingResources();
  53.         m_pUnkMarshaler.Release();
  54.     }
  55.  
  56.     //  IMediaObjectImpl callbacks
  57.     HRESULT InternalGetInputStreamInfo(DWORD dwInputStreamIndex, DWORD *pdwFlags);
  58.     HRESULT InternalGetOutputStreamInfo(DWORD dwOutputStreamIndex, DWORD *pdwFlags);
  59.     HRESULT InternalCheckInputType(DWORD dwInputStreamIndex, const DMO_MEDIA_TYPE *pmt);
  60.     HRESULT InternalCheckOutputType(DWORD dwOutputStreamIndex, const DMO_MEDIA_TYPE *pmt);
  61.     HRESULT InternalGetInputType(DWORD dwInputStreamIndex, DWORD dwTypeIndex,
  62.                              DMO_MEDIA_TYPE *pmt);
  63.     HRESULT InternalGetOutputType(DWORD dwOutputStreamIndex, DWORD dwTypeIndex,
  64.                              DMO_MEDIA_TYPE *pmt);
  65.     HRESULT InternalGetInputSizeInfo(DWORD dwInputStreamIndex, DWORD *pcbSize,
  66.                              DWORD *pcbMaxLookahead, DWORD *pcbAlignment);
  67.     HRESULT InternalGetOutputSizeInfo(DWORD dwOutputStreamIndex, DWORD *pcbSize,
  68.                               DWORD *pcbAlignment);
  69.     HRESULT InternalGetInputMaxLatency(DWORD dwInputStreamIndex, REFERENCE_TIME *prtMaxLatency);
  70.     HRESULT InternalSetInputMaxLatency(DWORD dwInputStreamIndex, REFERENCE_TIME rtMaxLatency);
  71.     HRESULT InternalFlush();
  72.     HRESULT InternalDiscontinuity(DWORD dwInputStreamIndex);
  73.     HRESULT InternalAllocateStreamingResources();
  74.     HRESULT InternalFreeStreamingResources();
  75.     HRESULT InternalProcessInput(DWORD dwInputStreamIndex, IMediaBuffer *pBuffer,
  76.                                 DWORD dwFlags, REFERENCE_TIME rtTimestamp,
  77.                                 REFERENCE_TIME rtTimelength);
  78.     HRESULT InternalProcessOutput(DWORD dwFlags, DWORD cOutputBufferCount,
  79.                                 DMO_OUTPUT_DATA_BUFFER *pOutputBuffers,
  80.                                DWORD *pdwStatus);
  81.     HRESULT InternalAcceptingInput(DWORD dwInputStreamIndex);
  82.  
  83.  
  84.     //  Internal processing routine
  85.     HRESULT Process();
  86.  
  87.     CComPtr<IUnknown> m_pUnkMarshaler;
  88.  
  89.     //  Streaming locals
  90.     CComPtr<IMediaBuffer>  m_pBuffer;
  91.     BYTE *                 m_pbData;
  92.     DWORD                  m_cbData;
  93.  
  94.     //  Fabricate timestamps based on the average time per from if there isn't one in the stream
  95.     REFERENCE_TIME         m_rtFrame;
  96.  
  97.     //  Current state info
  98.     CStreamState           m_StreamState;
  99.     bool                   m_bPicture;
  100.  
  101. public:
  102. };
  103.  
  104. #endif //__SAMPLE_H_
  105.